#ifndef SIMPLERENDERER_H
#define SIMPLERENDERER_H

#include <QOpenGLBuffer>

#include "renderer.h"

class aiScene;

class SimpleRenderer: public Renderer
{
    Q_OBJECT
public:
    SimpleRenderer(QString modelDiskPath, QWindow* window);

    virtual void initialize();
    virtual void doRender();

private:
    void initializeProgram();
    void initializeBuffers();

    void initializeVertexPosBuffer(const aiScene *scene);
    void initializeVertexNormBuffer(const aiScene *scene);
    void initializeVertexMaterialData(const aiScene *scene);
    void readMaterialData(const aiScene *scene);

    void initializeBuffer(QOpenGLBuffer& buffer,  QVector<float> data, QString attribute);
    QVector<float> vertexPosData(const aiScene* scene,
                                 float &xMin, float &xMax,
                                 float &yMin, float &yMax,
                                 float &zMin, float &zMax);
    QVector<float> vertexNormData(const aiScene* scene);

    void calculateScaleAndOffset(float xMin, float xMax,
                                 float yMin, float yMax,
                                 float zMin, float zMax);

    QVector<float> vertexMaterialData(const aiScene *scene);
    QVector<float> m_vertexMaterialData;
    QVector<QVector3D> m_materialKaData;
    QVector<QVector3D> m_materialKdData;
    QVector<QVector3D> m_materialKsData;

    QOpenGLVertexArrayObject* m_vao;
    QOpenGLShaderProgram* m_program;
    QOpenGLBuffer m_vertexPosBuffer;
    QOpenGLBuffer m_vertexNormBuffer;
    QOpenGLBuffer m_facesBuffer;

    int m_vertexCount;
};

#endif // SIMPLERENDERER_H
